from torch.nn import Linear, Module, Flatten, MaxPool2d, Conv2d, Sequential
import torch

class MyCifarModel(Module):
    def __init__(self):
        super(MyCifarModel, self).__init__()
        self.model1 = Sequential(
            Conv2d(3, 32, 3, padding=2),
            MaxPool2d(2),
            Conv2d(32, 32, 5, padding=2),
            MaxPool2d(2),
            Conv2d(32, 64, 5, padding=2),
            MaxPool2d(2),
            Flatten(),
            Linear(1024, 64),
            Linear(64, 10)
        )

    def forward(self, x):
        return self.model1(x)

my_model = MyCifarModel()
print(my_model)

# 使用生成数据来测试
x = torch.ones(1, 3, 32, 32)
y = my_model(x)
print(y.shape)